Skip to content

Conversation

@lla-dane
Copy link
Contributor

@lla-dane lla-dane commented Sep 1, 2025

Tracks #768
WIP: The libp2p-record module for py-libp2p in reference with the go-libp2p-record repo.

Reference: https://github.com/libp2p/go-libp2p-record

@lla-dane
Copy link
Contributor Author

lla-dane commented Sep 1, 2025

This PR is same as #776, that branch got deleted by mistake at my end. @seetadev @sumanjeet0012

@seetadev
Copy link
Contributor

seetadev commented Sep 1, 2025

@lla-dane : Great, thank you so much Abhinav.

Re-ran the CI/CD pipeline.1 test case is failing. Please fix the issue.

@seetadev
Copy link
Contributor

seetadev commented Sep 1, 2025

@acul71 : Looks like an unrelated test case ( FAILED tests/core/pubsub/test_gossipsub_px_and_backoff.py) is failing the CI/CD checks. We can fix this in another issue.

@lla-dane can make the requisite changes.

@seetadev
Copy link
Contributor

seetadev commented Sep 8, 2025

@lla-dane : Hi Abhinav. @sumanjeet0012 will be focusing on kad-dht refactor. Please coordinate with him to ensure smooth integration with libp2p-record module.

@lla-dane
Copy link
Contributor Author

lla-dane commented Sep 10, 2025

Hey @sumanjeet0012, any updates with the kad-dht refactor.

@sumanjeet0012
Copy link
Contributor

@lla-dane As we’ve previously encountered redundancy by working on the same task simultaneously, I’m currently holding off on proceeding further. Once your PR is completed, I’ll begin the remaining refactoring work on the Kademlia DHT. This approach should help us avoid duplication of effort and ensure a more efficient workflow.

@lla-dane lla-dane mentioned this pull request Sep 15, 2025
15 tasks
- updated the value-store to store key/value pairs in record pb format
- Updated the tests related to this change
Comment on lines +283 to +301
# TEST PUB-KEY VALIDATORS

# VALID KEY PAIR
keypair = create_new_key_pair()
peer_id = ID.from_pubkey(keypair.public_key)
key = f"/pk/{peer_id.to_bytes().hex()}"
value = keypair.public_key.serialize()

with trio.fail_after(TEST_TIMEOUT):
await dht_a.put_value(key.encode(), value)

# INVALID KEY PAIR
key = "/pk/abcdef1234567890" # Not a valid multihash
value = b"not-a-real-key"

with trio.fail_after(TEST_TIMEOUT):
with pytest.raises(InvalidRecordType, match="valid multihash"):
await dht_a.put_value(key.encode(), value)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seetadev: Tests showing the integration of libp2p-record-module PK validators with kad-dht

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lla-dane : Great, thank you so much for sharing.

@lla-dane
Copy link
Contributor Author

lla-dane commented Oct 12, 2025

@seetadev: Updated the KAD-DHT value-store to store the key/value pairs in protobuf record format in c632824

Now the libp2p-record-module was basically about namespace validators, in which PublicKey validators was already implemented. So now the Namespace validator utils (from libp2p-record-module) is properly integrated with the kad-dht.
Added the tests showing the PublicKey record validators.
Now need to figure out what to do with the IPNS record validators(Could also hold off on it for the time being).

@lla-dane lla-dane changed the title WIP: libp2p-record module in reference with go-libp2p-record libp2p-record module in reference with go-libp2p-record Oct 12, 2025
- Create docs/libp2p.records.rst
- Update docs/libp2p.peer.rst with new files added
- Add test suite for pk type dht records
@lla-dane
Copy link
Contributor Author

@seetadev: This is the place IPNS validators (from ipfs repo) come into the scene, in go-libp2p-kad-dht repo.

https://github.com/libp2p/go-libp2p-kad-dht/blob/8e4cda0bf2c0733830641bb940bb0682e8c31b94/internal/config/config.go#L101C1-L103C5

@seetadev
Copy link
Contributor

Excellent work @lla-dane — this is a really solid update! 🚀

Great to see the protobuf record format now integrated cleanly into the KAD-DHT value store and the namespace validator utils from the libp2p-record module properly wired in. The addition of PublicKey record validator tests is a strong step toward aligning py-libp2p with the go-libp2p implementation.

We can definitely hold off on the IPNS record validators for now and revisit once we sync up with the IPFS integration path — your note and the reference to the go-libp2p-kad-dht config are spot on.

Everything looks good for final review and merge — excellent progress!

@seetadev seetadev merged commit 663e3ac into libp2p:main Oct 13, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants